import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Scanner;

public class Main050401 {

	    /*remove函数代码*/

	    /*covnertStringToList函数代码*/
	/*以空格为分隔符，将line转换为List<String>*/
	public static List<String> convertStringToList(String line) {
		List<String>strlist=new ArrayList<>();
		Scanner sc=new Scanner(line);
		while(sc.hasNext()){
			strlist.add(sc.next());
		}
		return strlist;
	}
	/*在list中移除掉以与str内容相同的元素*/
	public static void remove(List<String> list, String str){
		for(Iterator<String> iterator=list.iterator();iterator.hasNext();){
			String str1=(String) iterator.next();
			if(str1.equals(str))
				iterator.remove();
		}
	}
	    public static void main(String[] args) {
	        Scanner sc = new Scanner(System.in);
	        while(sc.hasNextLine()){
	            List<String> list = convertStringToList(sc.nextLine());
	            System.out.println(list);
	            String word = sc.nextLine();
	            remove(list,word);
	            System.out.println(list);
	        }
	        sc.close();
	    }

}
